﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using Distrackting.DataLayer;
using Distrackting.BusinessLayer;
using System.Collections.Generic;
using Microsoft.Live.ServerControls.VE;

namespace Distrackting.PresentationLayer
{

    public partial class TesteMapas : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Session["duplicado"] = false;
                Session.Remove("linha");

            }
        }

        protected void Map1_ServerClick(object sender, MapEventArgs e)
        {
            if (e.rightMouseButton)
            {
                bool duplicado = (bool)Session["duplicado"];
                if (duplicado == false)
                {
                    if (Session["linha"] == null)
                    {
                        Shape linha = new Shape();
                        linha.Type = ShapeType.Polyline;
                        linha.HideIcon();
                        linha.Points.Add(new LatLongWithAltitude(e.latLong.Latitude, e.latLong.Longitude));
                        Session.Add("linha", linha);
                    }
                    else
                    {
                        Shape linha = (Shape)Session["linha"];
                        linha.Points.Add(new LatLongWithAltitude(e.latLong.Latitude, e.latLong.Longitude));
                        Map1.DeleteAllShapes();
                        Map1.AddShape(linha);
                    }
                    Session["duplicado"] = true;
                }
                else Session["duplicado"] = false;
                    
            }               
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            Label5.Text = Map1.GetShapeLayerCount().ToString();
        }
    }      
}
